package com.example.leave;
import javax.swing.*;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import javax.swing.table.DefaultTableModel;

public class Teacher {
	private String teacherId;
	public Teacher(String teacherId) {
		this.teacherId = teacherId;
        createAndShowGUI();
    }
	private void createAndShowGUI() {
		// 创建主窗口
        JFrame frame = new JFrame("教师页面");

        // 创建面板
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        // 创建表格面板
        JPanel tablePanel = new JPanel();
        tablePanel.setLayout(new BorderLayout());
        String[] columnNames = {"学号", "姓名", "请假时间","请假原因", "状态"};
        DefaultTableModel tableModel = new DefaultTableModel(columnNames, 0);
        JTable table = new JTable(tableModel);
        JScrollPane scrollPane = new JScrollPane(table);
        tablePanel.add(scrollPane, BorderLayout.CENTER);
        // 添加组件到主面板
        panel.add(tablePanel);
     // 查看和修改按钮
        JPanel actionPanel = new JPanel();
        actionPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); // 居中对齐
        JButton viewButton = new JButton("查看");
        JButton editButton = new JButton("取消");
        // 创建取消按钮并添加事件监听器
        editButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
            	frame.dispose();
            }
        });

     // 添加按钮到动作面板
        actionPanel.add(viewButton);
        actionPanel.add(editButton);
        panel.add(actionPanel);
        // 设置窗口属性
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(600, 400);
        frame.add(panel);
        frame.setVisible(true);
        
	}
	

	

}
